from typing import Any, Optional
from fastapi.responses import JSONResponse
from fastapi import status

class Response:
    @staticmethod
    def success(
        data: Any = None,
        message: str = "Success",
        status_code: int = status.HTTP_200_OK
    ) -> JSONResponse:
        return JSONResponse(
            status_code=status_code,
            content={
                "success": True,
                "message": message,
                "data": data
            }
        )

    @staticmethod
    def error(
        message: str = "Error",
        status_code: int = status.HTTP_400_BAD_REQUEST,
        error_code: Optional[str] = None
    ) -> JSONResponse:
        content = {
            "success": False,
            "message": message
        }
        if error_code:
            content["error_code"] = error_code
        return JSONResponse(
            status_code=status_code,
            content=content
        ) 